package com.itheima.IODemo;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Demo03 {

    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("20240417\\a.txt");
        byte[] words={97,98,99,100,101};
        for (int i = 0; i <words.length ; i++) {
            fos.write(words[i]);
            fos.write("\r\n".getBytes(StandardCharsets.UTF_8));
        }
        fos.close();
    }

    private static void hanghang() throws IOException {
        //换行
        FileOutputStream fos = new FileOutputStream("20240417\\a.txt",false);
        byte[] words={97,98,99,100,101};
        for (int i = 0; i <words.length ; i++) {
            fos.write(words[i]);
            fos.write("\r\n".getBytes());//传入一个换行的数据
        }
        fos.close();
    }

    private static void xuxie() throws IOException {
        //续写
        FileOutputStream fos = new FileOutputStream("20240417\\a.txt",false);
        byte[] b = "abcde".getBytes();
        fos.write(b);

        fos.close();
    }
}
